﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/AdminFunction.Master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="BitPortal.Admin.Article.Article.Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .x-grid3-cell-inner
        {
            font-family: "segoe ui" ,tahoma, arial, sans-serif;
        }
        
        .x-grid-group-hd div
        {
            font-family: "segoe ui" ,tahoma, arial, sans-serif;
        }
        
        .x-grid3-hd-inner
        {
            font-family: "segoe ui" ,tahoma, arial, sans-serif;
            font-size: 12px;
        }
        
        .x-grid3-body .x-grid3-td-Cost
        {
            background-color: #f1f2f4;
        }
        
        .x-grid3-summary-row .x-grid3-td-Cost
        {
            background-color: #e1e2e4;
        }
    </style>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="TopBarHolder" runat="server">
    <ext:ButtonGroup ID="ButtonGroup1" runat="server" Layout="ToolbarLayout">
        <Items>
            <ext:Button runat="server" ID="btnAdd" Text="Thêm bài viết" Icon="PageAdd" Scale="Medium"
                CausesValidation="false">
                <DirectEvents>
                    <Click OnEvent="btnAdd_Click">
                        <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                    </Click>
                </DirectEvents>
            </ext:Button>
            <ext:ToolbarSeparator />
            <ext:Button runat="server" ID="btnEdit" Text="Sửa bài viết" Icon="Pencil" Scale="Medium"
                CausesValidation="false">
                <DirectEvents>
                    <Click OnEvent="btnEdit_Click">
                        <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                    </Click>
                </DirectEvents>
            </ext:Button>
            <ext:ToolbarSeparator />
            <ext:SplitButton runat="server" ID="btnUpdate" Text="Cập nhật" Icon="PageEdit" Scale="Medium">
                <Menu>
                    <ext:Menu ID="Menu1" runat="server">
                        <Items>
                            <ext:MenuItem ID="MenuItem1" runat="server" Text="Duyệt" Icon="Accept">
                                <Listeners>
                                    <Click Handler="#{Window3}.show();" />
                                </Listeners>
                            </ext:MenuItem>
                            <ext:MenuItem ID="MenuItem3" runat="server" Text="Hiển thị" Icon="Eye">
                                <Listeners>
                                    <Click Handler="#{Window4}.show();" />
                                </Listeners>
                            </ext:MenuItem>
                            <ext:MenuItem ID="MenuItem4" runat="server" Text="Tin nổi bật" Icon="New">
                                <Listeners>
                                    <Click Handler="#{Window5}.show();" />
                                </Listeners>
                            </ext:MenuItem>
                            <ext:MenuItem ID="MenuItem5" runat="server" Text="Chuyển sang nhóm bài viết khác"
                                Icon="FolderGo">
                                <Listeners>
                                    <Click Handler="#{Window2}.show();" />
                                </Listeners>
                            </ext:MenuItem>
                        </Items>
                    </ext:Menu>
                </Menu>
            </ext:SplitButton>
            <ext:ToolbarSeparator />
            <ext:Button runat="server" ID="btnDelete" Text="Xóa bài viết" Icon="PageDelete" Scale="Medium">
                <DirectEvents>
                    <Click OnEvent="btnDelete_Click">
                        <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                    </Click>
                </DirectEvents>
            </ext:Button>
            <ext:ToolbarSeparator />
            <ext:SplitButton runat="server" ID="btnTrash" Text="Thùng rác" Icon="Bin" Scale="Medium">
                <Menu>
                    <ext:Menu ID="Menu2" runat="server">
                        <Items>
                            <ext:MenuItem ID="MenuItem8" runat="server" Text="Xóa tất cả" Icon="Cancel">
                                <DirectEvents>
                                    <Click OnEvent="btnTrashEmpty_Click">
                                        <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                                    </Click>
                                </DirectEvents>
                            </ext:MenuItem>
                            <ext:MenuItem ID="MenuItem9" runat="server" Text="Xóa những bài được chọn" Icon="BinEmpty">
                                <DirectEvents>
                                    <Click OnEvent="btnTrashDelete_Click">
                                        <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                                    </Click>
                                </DirectEvents>
                            </ext:MenuItem>
                            <ext:MenuItem ID="MenuItem10" runat="server" Text="Bỏ khỏi thùng rác" Icon="ArrowTurnLeft">
                                <DirectEvents>
                                    <Click OnEvent="btnUnDelete_Click">
                                        <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                                    </Click>
                                </DirectEvents>
                            </ext:MenuItem>
                        </Items>
                    </ext:Menu>
                </Menu>
                <DirectEvents>
                    <Click OnEvent="btnTrash_Click">
                        <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                    </Click>
                </DirectEvents>
            </ext:SplitButton>
        </Items>
    </ext:ButtonGroup>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <ext:Store ID="Store1" runat="server" OnRefreshData="Store1_RefreshData" RemoteSort="true" RemotePaging="true">
        <Proxy>
            <ext:PageProxy />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="ArticleID">
                <Fields>
                    <ext:RecordField Name="ArticleID" Type="Int" />
                    <ext:RecordField Name="Title" Type="String" />
                    <ext:RecordField Name="ThumbImage" Type="String" />
                    <ext:RecordField Name="Tags" Type="String" />
                    <ext:RecordField Name="GroupName" Type="String" />
                    <ext:RecordField Name="ArticleCategory_Name" Type="String" ServerMapping="ArticleCategory.Name" />
                    <ext:RecordField Name="DatetimeDisplay" Type="Date" DateFormat="yyyy-MM-ddTHH:mm:ss" />
                    <ext:RecordField Name="IsEnabled" Type="Boolean" />
                    <ext:RecordField Name="IsHot" Type="Boolean" />
                    <ext:RecordField Name="IsApproved" Type="Boolean" />
                    <ext:RecordField Name="Logs_DatetimeCreated" Type="Date" ServerMapping="Logs.DatetimeCreated" />
                    <ext:RecordField Name="Statistic_ViewCount" Type="Auto" ServerMapping="Statistic.ViewCount" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="start" Value="0" Mode="Raw" />
            <ext:Parameter Name="limit" Value="10" Mode="Raw" />
            <ext:Parameter Name="sort" Value="" />
            <ext:Parameter Name="dir" Value="" />
        </BaseParams>
        <SortInfo Field="ArticleID" Direction="DESC" />
    </ext:Store>
    <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true" Title="Danh sách bài viết"
        StoreID="Store1">
        <ColumnModel ID="ColumnModel1" runat="server">
            <Columns>
                <ext:Column Header="Mã" DataIndex="ArticleID" Groupable="false" />
                <ext:TemplateColumn Header="Ảnh" Groupable="false" Sortable="false">
                    <Template ID="Template1" runat="server">
                        <Html>
                            <img src="/Handlers/Thumbnail.ashx?p={ThumbImage}&w=80&h=60" width="80" height="60" alt="" />
                        </Html>
                    </Template>
                </ext:TemplateColumn>
                <ext:GroupingSummaryColumn Header="Chuyên mục" DataIndex="ArticleCategory_Name" Groupable="true"
                    SummaryType="Count">
                    <SummaryRenderer Handler="return ((value === 0 || value > 1) ? '(' + value +' Bài viết)' : '(1 Bài viết)');" />
                </ext:GroupingSummaryColumn>
                <ext:Column Header="Tiêu đề" DataIndex="Title" Groupable="false" />
                <ext:Column Header="Tags" DataIndex="Tags" Groupable="false" />
                <ext:Column Header="Nhóm" DataIndex="GroupName" Hidden="true" />
                <ext:Column Header="Lượt xem" DataIndex="Statistic_ViewCount" Align="Center" />
                <ext:DateColumn Header="Ngày hiển thị" DataIndex="DatetimeDisplay" Align="Center"
                    Format="dd-MM-yyyy" />
                <ext:DateColumn Header="Ngày tạo" DataIndex="Logs_DatetimeCreated" Align="Center" Format="dd-MM-yyyy"/>
                <ext:Column Header="Hiển thị" DataIndex="IsEnabled" Align="Center">
                    <Renderer Handler="return (value) ? 'Có':'Không';" />
                </ext:Column>
                <ext:Column Header="Tin nổi bật" DataIndex="IsHot" Align="Center">
                    <Renderer Handler="return (value) ? 'Có':'Không';" />
                </ext:Column>
                <ext:Column Header="Trạng thái" DataIndex="IsApproved" Align="Center">
                    <Renderer Handler="return (value) ? 'Đã duyệt':'Chưa duyệt';" />
                </ext:Column>
            </Columns>
        </ColumnModel>
        <SelectionModel>
            <ext:CheckboxSelectionModel ID="CheckboxSelectionModel1" runat="server" />
        </SelectionModel>
        <View>
            <ext:GroupingView ID="GroupingView1" runat="server" ForceFit="true" MarkDirty="false"
                ShowGroupName="true" EnableNoGroups="true" HideGroupedColumn="true" ShowGroupsText="Nhóm lại theo cột này" />
        </View>
        <LoadMask ShowMask="true" />
        <Plugins>
            <ext:GridFilters runat="server" ID="GridFilters1">
                <Filters>
                    <ext:NumericFilter DataIndex="ArticleID" />
                    <ext:StringFilter DataIndex="ArticleCategory_Name" />
                    <ext:StringFilter DataIndex="Title" />
                    <ext:StringFilter DataIndex="Tags" />
                    <ext:NumericFilter DataIndex="Statistic_ViewCount" />
                    <ext:DateFilter DataIndex="DatetimeDisplay">
                        <DatePickerOptions runat="server" TodayText="Now" />
                    </ext:DateFilter>

                    <ext:DateFilter DataIndex="Logs_DatetimeCreated">
                        <DatePickerOptions runat="server" TodayText="Now" />
                    </ext:DateFilter>

                    <ext:BooleanFilter DataIndex="IsEnabled" />
                    <ext:BooleanFilter DataIndex="IsHot" />
                    <ext:BooleanFilter DataIndex="IsApproved" />
                </Filters>
            </ext:GridFilters>
        </Plugins>
        <BottomBar>
            <ext:PagingToolbar ID="PagingToolbar1" runat="server" PageSize="10" />
        </BottomBar>
    </ext:GridPanel>
    <uc:ArticleAddEdit ID="ArticleAddEdit1" runat="server" ReloadGrid="GridPanel1" />
    <ext:Window ID="Window2" runat="server" Collapsible="true" Icon="ApplicationEdit" Title="Title"
        Width="500" AutoScroll="true" AutoHeight="true" Hidden="true">
        <Content>
            <ext:Panel runat="server" ButtonAlign="Center" Layout="FormLayout" Padding="20">
                <Content>
                    <uc:CBArticleCategory ID="CBArticleCategory2" runat="server" />
                </Content>
                <Buttons>
                    <ext:Button runat="server" ID="btnSetCategory" Text="Cập nhật">
                        <DirectEvents>
                            <Click OnEvent="btnSetCategory_Click">
                                <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                            </Click>
                        </DirectEvents>
                    </ext:Button>
                </Buttons>
            </ext:Panel>
        </Content>
    </ext:Window>
    <ext:Window ID="Window3" runat="server" Collapsible="true" Icon="ApplicationEdit" Title="Title"
        Width="500" AutoScroll="true" AutoHeight="true" Hidden="true">
        <Content>
            <ext:Panel ID="Panel1" runat="server" ButtonAlign="Center" Layout="FormLayout" LabelWidth="50">
                <Items>
                    <ext:RadioGroup ID="rgApproved" runat="server" AnchorHorizontal="100%">
                        <Items>
                            <ext:Radio ID="rApproved" runat="server" FieldLabel="Đã duyệt" Checked="true">
                            </ext:Radio>
                            <ext:Radio ID="rNonApproved" runat="server" FieldLabel="Chưa duyệt">
                            </ext:Radio>
                        </Items>
                    </ext:RadioGroup>
                </Items>
                <Buttons>
                    <ext:Button runat="server" ID="btnSetApproved" Text="Cập nhật">
                        <DirectEvents>
                            <Click OnEvent="btnSetApproved_Click">
                                <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                            </Click>
                        </DirectEvents>
                    </ext:Button>
                </Buttons>
            </ext:Panel>
        </Content>
    </ext:Window>
    <ext:Window ID="Window4" runat="server" Collapsible="true" Icon="ApplicationEdit" Title="Title"
        Width="500" AutoScroll="true" AutoHeight="true" Hidden="true">
        <Content>
            <ext:Panel ID="Panel2" runat="server" ButtonAlign="Center" Layout="FormLayout" LabelWidth="50">
                <Items>
                    <ext:RadioGroup ID="rgEnabled" runat="server" AnchorHorizontal="100%">
                        <Items>
                            <ext:Radio ID="Radio5" runat="server" FieldLabel="Cho phép hiển thị" Checked="true">
                            </ext:Radio>
                            <ext:Radio ID="Radio6" runat="server" FieldLabel="Không cho phép hiển thị">
                            </ext:Radio>
                        </Items>
                    </ext:RadioGroup>
                </Items>
                <Buttons>
                    <ext:Button runat="server" ID="btnSetEnabled" Text="Cập nhật">
                        <DirectEvents>
                            <Click OnEvent="btnSetEnabled_Click">
                                <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                            </Click>
                        </DirectEvents>
                    </ext:Button>
                </Buttons>
            </ext:Panel>
        </Content>
    </ext:Window>
    <ext:Window ID="Window5" runat="server" Collapsible="true" Icon="ApplicationEdit" Title="Title"
        Width="500" AutoScroll="true" AutoHeight="true" Hidden="true">
        <Content>
            <ext:Panel ID="Panel3" runat="server" ButtonAlign="Center" Layout="FormLayout" LabelWidth="50">
                <Items>
                    <ext:RadioGroup ID="rgHot" runat="server" AnchorHorizontal="100%">
                        <Items>
                            <ext:Radio ID="Radio7" runat="server" FieldLabel="Tin nổi bật" Checked="true">
                            </ext:Radio>
                            <ext:Radio ID="Radio8" runat="server" FieldLabel="Bình thường">
                            </ext:Radio>
                        </Items>
                    </ext:RadioGroup>
                </Items>
                <Buttons>
                    <ext:Button runat="server" ID="btnSetHot" Text="Cập nhật">
                        <DirectEvents>
                            <Click OnEvent="btnSetHot_Click">
                                <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                            </Click>
                        </DirectEvents>
                    </ext:Button>
                </Buttons>
            </ext:Panel>
        </Content>
    </ext:Window>
</asp:Content>
